Skip to content

Offload traffic to static workers and use node as the proxy#13366

Draft
freddyaboulton wants to merge 31 commits intomainfrom
proxy-to-node
Draft

Offload traffic to static workers and use node as the proxy#13366
freddyaboulton wants to merge 31 commits intomainfrom
proxy-to-node

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

Description

Similar to #13351 but using the built-in node server for ssr mode as the proxy

  • In SSR Mode, node will now launch in front of the python server and not the other way around
  • node will proxy requests for static routes to the background workers. node will continue serving the requests for the ssr-related assets as well
  • This bypasses the Node proxy in the python server and offers huge speedups
  • Working with gr.Server + ZeroGPU (space) and gr.Blocks + ZeroGPU (space)
background_traffic client_breakdown client_latency

Architecture

  flowchart TD
      Client[Client / Browser]
      Client --> Node["<b>node :7860</b><br/>reverse proxy"]

      Node -- "/upload, /file=, /static,<br/>/assets, /svelte, /favicon.ico" --> Pool
      Node -- "/queue/*, /api/*, SSE" --> Main
      Node -- "/, /_app/*" --> node

     subgraph Pool["Static Workers (round-robin)"]
          W1["Worker 1 :7862<br/>uploads, downloads, static assets"]
          W2["Worker 2 :7863<br/>uploads, downloads, static assets"]
      end

      Main["<b>Main Server :7861</b><br/>queue, SSE, API, session state, ML inference"]

      Pool --> FS
      Main --> FS
      FS[("Shared filesystem<br/>/tmp/gradio/")]
Loading

AI Disclosure

We encourage the use of AI tooling in creating PRs, but the any non-trivial use of AI needs be disclosed. E.g. if you used Claude to write a first draft, you should mention that. Trivial tab-completion doesn't need to be disclosed. You should self-review all PRs, especially if they were generated with AI.

  • I used AI to... [fill here]
  • I did not use AI

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented May 5, 2026

🪼 branch checks and previews

Name Status URL
🦄 Changes detected! Details

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@self/app minor
gradio minor

  • Offload traffic to static workers and use node as the proxy

‼️ Changeset not approved. Ensure the version bump is appropriate for all packages before approving.

  • Maintainers can approve the changeset by checking this checkbox.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants